package com.example.home.model

import com.example.home.api.HomeApiService
import com.example.net.RetrofitUtils
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import javax.inject.Qualifier
import javax.inject.Singleton
@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class Home{

}
@Module
@InstallIn(SingletonComponent::class)//单例操作
object NetworkModel {
    @Home
    @Provides
    @Singleton
    fun provideRetrofit():Retrofit{
        return RetrofitUtils.getRetrofit()
    }
    @Provides
    @Singleton
    fun provideHomeService(@Home retrofit:Retrofit):HomeApiService{
        return retrofit.create(HomeApiService::class.java)
    }
}